<html>
<head>
  <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=ISO-8859-1">
  <title>pline.m</title>
<link rel="stylesheet" type="text/css" href="../../m-syntax.css">
</head>
<body>
<code>
<span class=defun_kw>function</span>&nbsp;<span class=defun_out>varargout</span>=<span class=defun_name>pline</span>(<span class=defun_in>arg1,arg2,arg3</span>)<br>
<span class=h1>%&nbsp;PLINE&nbsp;Plots&nbsp;line&nbsp;in&nbsp;2D.</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;<span class=help_field>Synopsis:</span></span><br>
<span class=help>%&nbsp;&nbsp;h=pline(W,b)</span><br>
<span class=help>%&nbsp;&nbsp;h=pline(W,b,line_style)</span><br>
<span class=help>%&nbsp;&nbsp;h=pline(model)</span><br>
<span class=help>%&nbsp;&nbsp;h=pline(model,options)</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;<span class=help_field>Description:</span></span><br>
<span class=help>%&nbsp;&nbsp;h=pline(W,b)&nbsp;plots&nbsp;the&nbsp;line&nbsp;in&nbsp;2D&nbsp;space&nbsp;described&nbsp;implicitely&nbsp;as</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;W'*x&nbsp;+&nbsp;b&nbsp;=&nbsp;0&nbsp;,</span><br>
<span class=help>%&nbsp;&nbsp;where&nbsp;W,&nbsp;x&nbsp;are&nbsp;vectors&nbsp;[2x1]&nbsp;and&nbsp;b&nbsp;is&nbsp;scalar&nbsp;or&nbsp;explicitely&nbsp;as</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;y&nbsp;=&nbsp;W*x&nbsp;+&nbsp;b&nbsp;,</span><br>
<span class=help>%&nbsp;&nbsp;where&nbsp;W,&nbsp;x&nbsp;and&nbsp;b&nbsp;are&nbsp;scalars.</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;&nbsp;h=pline(W,b,line_style)&nbsp;defines&nbsp;parameter&nbsp;line_style&nbsp;of&nbsp;plot&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;function&nbsp;(default&nbsp;'k-').</span><br>
<span class=help>%&nbsp;&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;h=pline(model)&nbsp;parameters&nbsp;of&nbsp;the&nbsp;line&nbsp;are&nbsp;given&nbsp;in&nbsp;structure&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;model&nbsp;with&nbsp;fields&nbsp;model.W&nbsp;and&nbsp;model.b.</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;&nbsp;h=pline(model,options)&nbsp;argument&nbsp;options&nbsp;controls&nbsp;apperance</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;of&nbsp;the&nbsp;plotted&nbsp;line;&nbsp;options.win&nbsp;[left&nbsp;right&nbsp;top&nbsp;bottom]&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;determines&nbsp;window&nbsp;to&nbsp;which&nbsp;the&nbsp;line&nbsp;is&nbsp;plotted&nbsp;and&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;&nbsp;options.line_style&nbsp;is&nbsp;described&nbsp;above.</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;<span class=help_field>Output:</span></span><br>
<span class=help>%&nbsp;&nbsp;h&nbsp;[1x1]&nbsp;handle&nbsp;of&nbsp;plotted&nbsp;line.</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;<span class=help_field>Example:</span></span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;Plot&nbsp;horizontal&nbsp;and&nbsp;vertical&nbsp;axes&nbsp;with&nbsp;dashed&nbsp;line:</span><br>
<span class=help>%&nbsp;&nbsp;figure;&nbsp;hold&nbsp;on;&nbsp;axis([-1&nbsp;1&nbsp;-1&nbsp;1]);</span><br>
<span class=help>%&nbsp;&nbsp;pline(inf,0,'--');&nbsp;</span><br>
<span class=help>%&nbsp;&nbsp;pline(0,0,'--');</span><br>
<span class=help>%</span><br>
<span class=help>%&nbsp;Plot&nbsp;Fisher&nbsp;linear&nbsp;discriminat&nbsp;for&nbsp;Riply's&nbsp;data&nbsp;set:</span><br>
<span class=help>%&nbsp;&nbsp;data&nbsp;=&nbsp;load('riply_trn');</span><br>
<span class=help>%&nbsp;&nbsp;model&nbsp;=&nbsp;lfld(&nbsp;mlcgmm(data));</span><br>
<span class=help>%&nbsp;&nbsp;figure;&nbsp;ppatterns(data);</span><br>
<span class=help>%&nbsp;&nbsp;pline(model);</span><br>
<span class=help>%</span><br>
<hr>
<br>
<span class=help1>%&nbsp;<span class=help1_field>About:</span>&nbsp;Statistical&nbsp;Pattern&nbsp;Recognition&nbsp;Toolbox</span><br>
<span class=help1>%&nbsp;(C)&nbsp;1999-2003,&nbsp;Written&nbsp;by&nbsp;Vojtech&nbsp;Franc&nbsp;and&nbsp;Vaclav&nbsp;Hlavac</span><br>
<span class=help1>%&nbsp;&lt;a&nbsp;href="http://www.cvut.cz"&gt;Czech&nbsp;Technical&nbsp;University&nbsp;Prague&lt;/a&gt;</span><br>
<span class=help1>%&nbsp;&lt;a&nbsp;href="http://www.feld.cvut.cz"&gt;Faculty&nbsp;of&nbsp;Electrical&nbsp;Engineering&lt;/a&gt;</span><br>
<span class=help1>%&nbsp;&lt;a&nbsp;href="http://cmp.felk.cvut.cz"&gt;Center&nbsp;for&nbsp;Machine&nbsp;Perception&lt;/a&gt;</span><br>
<br>
<span class=help1>%&nbsp;<span class=help1_field>Modifications:</span></span><br>
<span class=help1>%&nbsp;29-apr-2004,&nbsp;VF</span><br>
<span class=help1>%&nbsp;13-july-2003,&nbsp;VF</span><br>
<span class=help1>%&nbsp;20-jan-2003,&nbsp;VF</span><br>
<span class=help1>%&nbsp;8-jan-2003,&nbsp;VF,&nbsp;A&nbsp;new&nbsp;coat.</span><br>
<br>
<hr>
oldhold=ishold;<br>
hold&nbsp;on;<br>
<br>
<span class=keyword>if</span>&nbsp;<span class=stack>nargin</span>&nbsp;&gt;=&nbsp;2&nbsp;&&nbsp;isstruct(arg2)==0,<br>
&nbsp;&nbsp;&nbsp;model.W&nbsp;=&nbsp;arg1;<br>
&nbsp;&nbsp;&nbsp;model.b&nbsp;=&nbsp;arg2;<br>
&nbsp;&nbsp;&nbsp;<span class=keyword>if</span>&nbsp;<span class=stack>nargin</span>&nbsp;&gt;&nbsp;2,&nbsp;options.line_style&nbsp;=&nbsp;arg3;&nbsp;<span class=keyword>else</span>&nbsp;options&nbsp;=&nbsp;[];&nbsp;<span class=keyword>end</span><br>
<span class=keyword>else</span><br>
&nbsp;&nbsp;model=c2s(arg1);<br>
&nbsp;&nbsp;<span class=keyword>if</span>&nbsp;<span class=stack>nargin</span>&nbsp;&lt;&nbsp;2,&nbsp;options&nbsp;=&nbsp;[];&nbsp;<span class=keyword>else</span>&nbsp;options=c2s(arg2);&nbsp;<span class=keyword>end</span><br>
<span class=keyword>end</span><br>
<br>
<span class=keyword>if</span>&nbsp;~isfield(options,<span class=quotes>'win'</span>),&nbsp;options.win&nbsp;=&nbsp;<span class=graph>axis</span>;&nbsp;<span class=keyword>end</span><br>
<span class=keyword>if</span>&nbsp;~isfield(options,<span class=quotes>'line_style'</span>),&nbsp;options.line_style&nbsp;=&nbsp;<span class=quotes>'k-'</span>;&nbsp;<span class=keyword>end</span><br>
<br>
<span class=keyword>if</span>&nbsp;length(model.W)==1,<br>
&nbsp;&nbsp;&nbsp;model.W&nbsp;=&nbsp;[model.W;&nbsp;-1];<br>
<span class=keyword>end</span><br>
<br>
[x1,y1,x2,y2,in]=clipline(model.W,model.b,options.win);<br>
<br>
h&nbsp;=&nbsp;<span class=graph>plot</span>([x1,x2],[y1,y2],options.line_style);<br>
<span class=keyword>if</span>&nbsp;<span class=stack>nargout</span>&gt;0,&nbsp;<span class=stack>varargout</span>{1}=&nbsp;h;&nbsp;<span class=keyword>end</span><br>
<br>
<span class=keyword>if</span>&nbsp;~oldhold,&nbsp;hold&nbsp;off;&nbsp;<span class=keyword>end</span><br>
<br>
<span class=jump>return</span>;<br>
<br>
</code>
